From 33339c68eb03ced47eff33b9f6678a92e5931c95 Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Fri, 16 May 2014 12:49:36 -0400 Subject: [PATCH] API: Remove XML tag highlighting from non-XML formats Since 926afc65c316, the transformation assumes < and > occur in pairs. This assumption is invalid for formats such as JSON. Implementing proper JSON syntax highlighting falls outside the scope of this workaround and is left for separate changes, likely including the addition of a hook. That is part of the API roadmap RfC. https://www.mediawiki.org/wiki/Requests_for_comment/API_roadmap#Changes_to_pretty-printed_HTML_formats Bug: 65403 Change-Id: Iff8d444c82f7efd2bd1c9f703defc4f0984e8211 --- RELEASE-NOTES-1.25 | 4 +++- includes/api/ApiFormatBase.php | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index c8bea32a6c..70f175bc3f 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -25,10 +25,12 @@ changes to languages because of Bugzilla reports. === Other changes in 1.25 === * The skin autodiscovery mechanism, deprecated in MediaWiki 1.23, has been removed. See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for - migration guide for creators and users of custom skins that relied on it. + migration guide for creators and users of custom skins that relied on it. * Javascript variable 'wgFileCanRotate' now only available on Special:Upload. * (bug 56257) Set site logo url in ResourceLoaderSiteModule instead of inline styles in the HTML output. +* (bug 65403) XML tag highlighting is now only performed for formats + "xmlfm" and "wddxfm". == Compatibility == diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 9165ce8805..2a576886f3 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -278,9 +278,12 @@ See the complete documentation, protected function formatHTML( $text ) { // Escape everything first for full coverage $text = htmlspecialchars( $text ); - // encode all comments or tags as safe blue strings - $text = str_replace( '<', '<', $text ); - $text = str_replace( '>', '>', $text ); + + if ( $this->mFormat === 'XML' || $this->mFormat === 'WDDX' ) { + // encode all comments or tags as safe blue strings + $text = str_replace( '<', '<', $text ); + $text = str_replace( '>', '>', $text ); + } // identify requests to api.php $text = preg_replace( '#^(\s*)(api\.php\?[^ <\n\t]+)$#m', '\1\2', $text ); -- 2.20.1